﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace 第六次课堂作业
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = openFileDialog1.ShowDialog();
            string fileName = openFileDialog1.FileName;
            if (dialogResult == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(fileName))   //当点击按钮同时文件名不为空时读取文件
            {
                StreamReader sr = new StreamReader(fileName);
                textBox1.Text += "\n" + sr.ReadToEnd();       //StreamReader.ReadToEnd 方法读取来自流的当前位置到结尾的所有字符。
                sr.Close();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            form2.content = textBox1.Text;
            form2.Show();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
        }
    }
}
